package com.huangfu.learning.javabase.java.base;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/11/19
 * Time: 11:30
 * Version: 1.0
 * Description: 接口作为参数,调用的地方是实现类
 **/
public class InterfaceAsParam {

    public static void main(String[] args) {

        Linux debian = new Linux();
        Windows win10 = new Windows();
        ShowAdvt feature = new ShowAdvt();
        feature.showA(debian);
        feature.showA(win10);
    }

}

// 接口 优势
interface Advantage {
    void show();
}

// 实现类1 Linux系统
class Linux implements Advantage {
    public void show() {
        System.out.println("Linux OpenSource");
    }
}

// 实现类2 windows系统
class Windows implements Advantage {
    public void show() {
        System.out.println("Windows Easy to use");
    }
}

// 接口作为参数
class ShowAdvt {
    // 这里的入参是实现类，根据实现类来决定调用哪个实现方法
    void showA(Advantage a) {
        a.show();
    }
}
